﻿#ifndef CIsapiClient_H
#define CIsapiClient_H
/********************************************************************************
** @ Date:2025/01/08
** @ Author: HanJiaXin
** @ Description:isapi客户端
** @ Version:1.0.0
** @ ClassName:CIsapiClient
** @ Fun:
********************************************************************************/
#include <QObject>
#include <QUrl>
#include <QNetworkAccessManager>

struct SRequestResult
{
	bool bResult;//是否成功
	QByteArray sResult;//回复内容
	QString sErrorMessage;//错误信息
	SRequestResult()
	{
		bResult = false;
		sResult = "";
		sErrorMessage = "";
	}
};

class CIsapiClient  : public QObject
{
	Q_OBJECT

public:
	CIsapiClient(const QString &username, const QString &password, QObject *parent = nullptr);
	CIsapiClient();
	~CIsapiClient();

	void setData(QString sUserName, QString sPasswd);

	void sendRequestGet(int nRequestType,QUrl &url);
	void sendRequestGet(int nRequestType,QString sParam, QUrl &url);//带参数的Get请求
	void sendRequestPost(int nRequestType, QUrl &url, QByteArray postData);

private slots:
	void slotAuthenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator);

signals:
	void sigResult(int nRequestType,SRequestResult stRequestResult);
	void sigResultParam(int nRequestType, QString sParam, SRequestResult stRequestResult);//带参数的信号

private:
	QString m_sUsernName;
	QString m_sPassword;
	QNetworkAccessManager *m_pManager;
};

#endif